package com.dj.ms.enums;


import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * <br>
 * <p>日志级别</p>
 *
 * <br>
 *
 * @author ZJG
 * @version 1.0
 * @date 2021/9/27 下午2:37
 */
@Getter
public enum LogLevelEnum {

    DEBUG(-1, "DEBUG"),
    INFO(0, "INFO"),
    WARN(1, "WARN"),
    ERROR(2, "ERROR"),
    TRACE(3, "TRACE");

    private int value;
    private String name;

    LogLevelEnum(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public static LogLevelEnum typeOf(String name) {
        if (StringUtils.isBlank(name)) {
            return LogLevelEnum.INFO;
        }
        for (LogLevelEnum d: LogLevelEnum.values()) {
            if (StringUtils.equals(name, d.name())) {
                return d;
            }
        }
        return LogLevelEnum.INFO;
    }
}
